import { http } from '@/utils/request'
import type { Notification, UserNotificationSettings, ApiResponse } from '@/types'

// 获取用户通知
export const getUserNotifications = (params?: {
  page?: number;
  limit?: number;
  type?: string;
}): Promise<ApiResponse<{
  notifications: Notification[];
  total: number;
}>> => {
  return http.get('/client/notifications', { params })
}

// 标记通知已读
export const markNotificationRead = (id: number): Promise<ApiResponse<null>> => {
  return http.put(`/client/notifications/${id}/read`)
}

// 标记所有通知已读
export const markAllNotificationsRead = (): Promise<ApiResponse<null>> => {
  return http.put('/client/notifications/read-all')
}

// 获取通知设置
export const getNotificationSettings = (): Promise<ApiResponse<UserNotificationSettings>> => {
  return http.get('/client/user/notification-settings')
}

// 更新通知设置
export const updateNotificationSettings = (data: {
  pushEnabled?: boolean;
  emailEnabled?: boolean;
  performanceReminder?: boolean;
  voteReminder?: boolean;
}): Promise<ApiResponse<UserNotificationSettings>> => {
  return http.put('/client/user/notification-settings', data)
}

// 获取未读通知数量
export const getUnreadNotificationCount = (): Promise<ApiResponse<{
  count: number;
}>> => {
  return http.get('/client/notifications/unread-count')
} 